#include "GenerarPlanDeCarreraPage.h"

using namespace presentacion;

GenerarPlanDeCarreraPage::GenerarPlanDeCarreraPage(void)
{
	this->pantalla= SDL_SetVideoMode(500,500,24,SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_NOFRAME);
	this->fondo = SDL_LoadBMP(RUTA_IMAGEN_FONDO_PAGE);
	this->botonGenerarPlan = new Boton(RUTA_IMAGEN_BOTON_GENERAR_PLAN, 400, 20);
	this->botonSalir = new Boton(RUTA_IMAGEN_BOTON_SALIR, 400, 50);

	SDL_BlitSurface(this->fondo, NULL, this->pantalla, NULL);
	SDL_BlitSurface(this->botonSalir->GetImagen(), &(this->botonSalir->GetRecorte(0)), this->pantalla, &(this->botonSalir->GetRectangulo()));
	SDL_BlitSurface(this->botonGenerarPlan->GetImagen(), &(this->botonGenerarPlan->GetRecorte(0)), this->pantalla, &(this->botonGenerarPlan->GetRectangulo()));
	SDL_Flip(this->pantalla);
};

int GenerarPlanDeCarreraPage::CapturarEvento()
{
	SDL_Event evento;
	int accion = ACCION_CONTINUAR;
	while (accion == ACCION_CONTINUAR) 
	{
		if(SDL_PollEvent(&evento))
		{
			if (this->botonGenerarPlan->CapturarEvento(&evento)) 
			{
				SDL_BlitSurface(this->botonGenerarPlan->GetImagen(), &(this->botonGenerarPlan->GetRecorte()), this->pantalla, 
					&(this->botonGenerarPlan->GetRectangulo()));
				SDL_Flip(this->pantalla);
				if (evento.type == SDL_MOUSEBUTTONDOWN)
				{
					accion = ACCION_GENERAR_PLAN;
				}
			}
			if (this->botonSalir->CapturarEvento(&evento)) 
			{
				SDL_BlitSurface(this->botonSalir->GetImagen(), &(this->botonSalir->GetRecorte()), this->pantalla, 
					&(this->botonSalir->GetRectangulo()));
				SDL_Flip(this->pantalla);
				if (evento.type == SDL_MOUSEBUTTONDOWN)
				{
					accion = ACCION_SALIR;
				}
			}
		}	
		SDL_Flip(this->pantalla);
	}
	return accion;
};
